<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ page import="javax.servlet.http.HttpServletRequest"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%	
	//获取项目名
	String path = request.getContextPath();
	//获取tomcat 协议+地址+端口号+ 获取项目名
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	//out.println(basePath);
%>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../css/sweetalert.css">
<script src="../js/sweetalert-dev.js"></script>
<script src="<%=basePath %>jquery-3.5.1.js"></script>
<script
	src="<%=basePath %>bootstrap/bootstrap-3.3.7-dist/js/bootstrap.js"></script>
<link rel="stylesheet"
	href="<%=basePath %>bootstrap/bootstrap-3.3.7-dist/css/bootstrap.css">
<title>是否删除</title>
</head>
<body>
	<%
	
	String cId =  request.getParameter("cId");
	String cContent = request.getParameter("cContent");
	//out.println(rsName);
	//out.println(getType(rsName));
	%>

	<script type="text/javascript">
    	
    	console.log(<%=cId%>);
    	var cc = <%=cContent%>;
    	console.log(cc);
    	
    	
        swal({ 
		title: "确定要删除该评论："+cc+" ?", 
		text: "你将无法恢复该评论！", 
		type: "warning",
		showCancelButton: true, 
		confirmButtonColor: "#DD6B55",
		confirmButtonText: "确定删除！", 
		cancelButtonText: "取消删除！",
		closeOnConfirm: false, 
		closeOnCancel: false	
		},
		function(isConfirm){ 
			console.log("cId:"+<%=cId%>);
		if (isConfirm) { 
			//console.log(window.location.search);
			//var rsId = ;
			$.ajax({
				url:"<%=basePath %>backgroundServlet",
				type:"get",
				data:"mark=delC&cId="+<%=cId%>,
				dataType:"json",
				success:function(mes){
					if(mes==true){
						swal("删除！", "您的评论已经被删除。","success");
						window.location.href = "<%=basePath %>backgroundServlet?mark=bShowC&userId=${user.userId}&manage=${user.manage}";
						
					}else{
						alert("删除失败！");
						window.location.href = "<%=basePath %>backgroundServlet?mark=bShowC&userId=${user.userId}&manage=${user.manage}";
						
					}
				}
			});
			 
		} else { 
			swal("取消！", "您的评论是安全的:)",
		"error"); 
			window.location.href = "<%=basePath %>backgroundServlet?mark=bShowC&userId=${user.userId}&manage=${user.manage}";
		} 
    });
    </script>
</body>
</html>